﻿// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
#include "pch.h"
#include "BooleanNegationToVisibilityConverter.h"

using namespace Weathr;

using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Interop;

Object^ BooleanNegationToVisibilityConverter::Convert(Object^ value, TypeName targetType, Object^ parameter, String^ language)
{
    (void) targetType;	// Unused parameter
    (void) parameter;	// Unused parameter
    (void) language;	// Unused parameter

    auto boxedBool = dynamic_cast<Box<bool>^>(value) ;
    auto boolValue = (boxedBool != nullptr && boxedBool->Value);
    return (!boolValue ? Visibility::Visible : Visibility::Collapsed);
}

Object^ BooleanNegationToVisibilityConverter::ConvertBack(Object^ value, TypeName targetType, Object^ parameter, String^ language)
{
    (void) targetType;	// Unused parameter
    (void) parameter;	// Unused parameter
    (void) language;	// Unused parameter

    auto visibility = dynamic_cast<Box<Visibility>^>(value) ;
    return !(visibility != nullptr && visibility->Value == Visibility::Visible);
}
